# 协程之所以能处理并发, 遇见IO操作就切换 (什么时间切换回去??? )  变成cpu密集的操作了
import time
from greenlet import greenlet


def test1():
    print(12)
    gr2.switch()
    print(34)
    gr2.switch()


def test2():
    print(56)
    gr1.switch()
    print(78)


gr1 = greenlet(test1)  # 启动一个协程
gr2 = greenlet(test2)
gr1.switch()  # 手动切换


# def home():
#     print("in func home")
#     time.sleep(5) # get data from db
#     print("home exec done")
#
#
# def bbs():
#     print("in func bbs")
#     time.sleep(2)
#
#
# def login():
#     print("in func login")



